﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 开放封闭原则.终极版
{
    /// <summary>
    /// 解决switch  case问题
    /// </summary>
    public interface IBankClient
    {
        IBankProcess GetBankClient();
    }
    public class DepositeClient : IBankClient
    {
        public IBankProcess GetBankClient()
        {
            return new Deposite();
        }
    }
    public class DrowMoneyClient : IBankClient
    {
        public IBankProcess GetBankClient()
        {
            return new DrowMoney();
        }
    }
    public class BuyJiJinClient : IBankClient
    {
        public IBankProcess GetBankClient()
        {
            return new BuyJiJin();
        }
    }
    public class TransferClient : IBankClient
    {
        public IBankProcess GetBankClient()
        {
            return new Transfer();
        }
    }
    public class BankStuff4
    {
        private IBankProcess _bankProcess;
        public void HandleProcess(IBankClient bankClient)
        {
            //调用银行的业务系统，处理我们用户的需求；
            _bankProcess = bankClient.GetBankClient();
            _bankProcess.Process();
        }
    }
}
